package com.ssb.controller;

import java.io.IOException;

import java.net.URLEncoder;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ssb.util.Sha1Util;

/**
 * 微信支付接口
 * 
 * @author 胡俊 2016年9月30日 下午8:27:50
 */
@SuppressWarnings("serial")
@Controller
public class WxController {
	
	@RequestMapping("/auth")
	public void wx(String money,String describe,String phone,String adress,String remark,HttpServletResponse response) {
		String appid = "wx29ebd38093d2298b";// 商户参数
		String backUri = "http://www.yunll.cc/topayServlet";// 网页授权后要跳的链接
		String orderNo = appid + Sha1Util.getTimeStamp();
//		backUri = backUri + "?userId=bddd&orderNo=" + orderNo + "&describe="+describe+"&money="+money;
		backUri = backUri + "?userId=bddd&orderNo=" + orderNo + "&describe="+describe+"&money="+money+"&phone="+phone+"&adress="+adress+"&remark="+remark;
		backUri = URLEncoder.encode(backUri);
		String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" + "appid=" + appid + "&redirect_uri="
				+ backUri + "&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
		try {
			response.sendRedirect(url);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}